<?php
session_start();
require '../util/DBUtil.php';
/**
 * 向数据库购物车表中写入购买商品信息
 */
$userID = unserialize($_SESSION['login_user'])['id'];
$bookNo = $_GET['bookNo'];
$bookNum = $_GET['bookNum'];
$price = $_GET['onePrice'];

$db = new DBUtil();
$sql = "insert into item(userID,bookNo,bookNum,buyDate,pay,onePrice) values (?,?,?,?,?,?)";
date_default_timezone_set("PRC");
$pram = array($userID,$bookNo,$bookNum,date("Y-m-d"),0,$price);
 $success = $db->update($sql,$pram);
 if($success){
     echo "<script>alert('加入购物车成功');history.back()</script>";
 }else{
     echo "<script>alert('加入购物车失败,请先查看您的购物车');</script>";
 }
